import cv2 as cv
import urllib.request
import numpy as np




def get_img_from_url1(url):
    cv.namedWindow('d', 0)
    while True:
        try:
            imgSrc = urllib.request.urlopen(url)
        except:
            continue
        imgNp = np.array(bytearray(imgSrc.read()), dtype=np.uint8)
        img = cv.imdecode(imgNp, -1)
        cv.imshow('d', img)
        if cv.waitKey(5) > 0:
            cv.destroyAllWindows()
            break

if __name__ == '__main__':
    url = 'http://192.168.0.104/cam-hi.jpg'
    get_img_from_url1(url)